﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CKFinder;
using TracNghiemTinHocDaiCuong.BIZ;
using TracNghiemTinHocDaiCuong.Common;
using TracNghiemTinHocDaiCuong.ThucThe;

namespace TracNghiemTinHocDaiCuong
{
    public partial class ThemCauHoi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlChuDe.DataSource = ChuDeBIZ.LayDanhSach();
                ddlChuDe.DataBind();
                ckeNoiDung.Language = "vi";
                CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
                _FileBrowser.BasePath = "/ckfinder/";
                _FileBrowser.SetupCKEditor(ckeNoiDung);
            }
        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            CauHoi cauHoiMoi = new CauHoi();
            cauHoiMoi.NoiDung = ckeNoiDung.Text;
            cauHoiMoi.DapAnA = ckeDapAnA.Text;
            cauHoiMoi.DapAnB = ckeDapAnB.Text;
            cauHoiMoi.DapAnC = ckeDapAnC.Text;
            cauHoiMoi.DapAnD = ckeDapAnD.Text;
            cauHoiMoi.MaCD = Methods.ConvertNumber(ddlChuDe.SelectedValue);
            string doKho = ddlDoKho.SelectedItem.ToString();
            if (doKho == "Dễ")
                cauHoiMoi.DoKho = "D";
            if (doKho == "Trung Bình")
                cauHoiMoi.DoKho = "T";
            if (doKho == "Khó")
                cauHoiMoi.DoKho = "K";
            cauHoiMoi.DapAn = ddlDapAn.SelectedItem.ToString();
            CauHoiBIZ.Them(cauHoiMoi);
            ckeNoiDung.Text = "";
            ckeDapAnA.Text = "";
            ckeDapAnB.Text = "";
            ckeDapAnC.Text = "";
            ckeDapAnD.Text = "";
            lblThongBao.Text = "";
            lblThongBao.Text = "Bạn đã thêm câu hỏi thành công";
        }

        protected void btnXoaTuKhoa_Click(object sender, EventArgs e)
        {
            ckeNoiDung.Text = "";
            ckeDapAnA.Text = "";
            ckeDapAnB.Text = "";
            ckeDapAnC.Text = "";
            ckeDapAnD.Text = "";
            lblThongBao.Text = "";
        }

        protected void btnQuayLai_Click(object sender, EventArgs e)
        {
            Response.Redirect("QuanLyCauHoi.aspx");
        }
    }
}